<?php

namespace App\Http\Requests;

use App\Exceptions\exception\ApiExcetion;
use Illuminate\Foundation\Http\FormRequest;

class LoginRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'avatarUrl'=>'required',
          //  'city'=>'required',
            'nickName'=>'required',
          //  'province'=>'required',
            'code'=>'required',
        ];

    }
    public function messages()
    {
        return [
            'avatarUrl.required'=>'头像不能为空',
       //     'city.required'=>'城市不能为空',
            'nickname.required'=>'名称不能为空',
        //    'province.required'=>'省份不能为空',
            'code.required'=>'请传入小程序登录的code',
        ];
    }
    protected function failedValidation(\Illuminate\Contracts\Validation\Validator $validator)
    {

        throw new ApiExcetion($validator->errors()->first());
    }
}
